package com.kycxika.app.adapter;

import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.kycxika.app.R;

import java.util.ArrayList;

/**
 * Created by DELL on 2017/5/3.
 */
public class FreeExperienceAdapter extends BaseAdapter {
    private final ArrayList<String> mData;
    private final FragmentActivity mContext;

    public FreeExperienceAdapter(ArrayList<String> names, FragmentActivity activity) {
        this.mData = names;
        this.mContext = activity;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public String getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null) {
            convertView = View.inflate(mContext,R.layout.free_list_item,null);
            holder = new ViewHolder(convertView);
           convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.list_title.setText(mData.get(position));
        return convertView;
    }

    class ViewHolder{

        private ImageView title_img;
        private TextView list_title;

        public ViewHolder(View view){
            title_img = (ImageView) view.findViewById(R.id.title_img);
            list_title = (TextView) view.findViewById(R.id.list_title);
        }
    }
}
